#!/usr/bin/env  python2.7
#-*- coding: utf-8 -*-

import xml.etree.ElementTree as ET
import xml.dom.minidom as Dom
from xml.dom import minidom
import sys


def print_test(node_test):
    tmp =  node_test
    print tmp.tag + " : ",
    print tmp.attrib['id'] + "       ->",
    print(tmp.attrib['description'])
    childs = tmp.getchildren()
    for child in childs  :
        print_var(child)

def print_var(node_var):
    tmp =  node_var
    if tmp.tag != "Variation" :
        return
    print '    ',
    print tmp.tag + " :",
    print(tmp.attrib['id'])
def read_xml(file_name):
    '''''读xml文件'''
    # 加载XML文件（2种方法,一是加载指定字符串，二是加载指定文件）
    root = ET.parse(file_name)
    #root = ElementTree.fromstring(text)

    # 获取element的方法
    # 1 通过getiterator
    lst_node = root.getiterator("Test")
    print("test suite number -> %d" %len(lst_node))
    for node in lst_node:
        print_test(node)
        #break


help_msg = '''app read/write dom/et/sax  file
'''
if __name__ == "__main__" :
    if len(sys.argv) < 2:
        print help_msg
        exit(0)

    read_xml(sys.argv[1])
